<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>The CheckBox Tree and a cbtree/store FileStore</title>
    <style type="text/css">
      @import "../../../dijit/themes/claro/claro.css";
      @import "../../../dijit/themes/claro/document.css";
      @import "../../../dijit/tests/css/dijitTests.css";
      @import "../../themes/claro/claro.css";
      @import "../../icons/fileIconsApache.css";
    </style>

    <script type="text/javascript">
      var dojoConfig = {
            async: true,
            parseOnLoad: true,
            isDebug: false,
            baseUrl: "../../../",
            packages: [
              { name: "dojo",  location: "dojo" },
              { name: "dijit", location: "dijit" },
              { name: "cbtree",location: "cbtree" }
            ]
      };
    </script>

    <script type="text/javascript" src="../../../dojo/dojo.js"></script>
    <script type="text/javascript">
      require([
        "dojo/ready",
        "cbtree/Tree",                  // Checkbox tree
        "cbtree/extensions/TreeStyling",
        "cbtree/model/FileStoreModel",
        "cbtree/store/FileStore"
        ], function (ready, Tree, TreeStyling, FileStoreModel, FileStore) {

           // Because of the generic nature of this demo it has no knowledge of the file system layout
           // under the DOCUMENT_ROOT, therefore the 'basePath' is set to the document root itself.

          var store = new FileStore( { url: "../../store/server/PHP/cbtreeFileStore.php",
                                        basePath:"./",
                                        options:["iconClass"],
                                        sort: [{attribute:"directory"},{attribute:"name", ignoreCase: true}]
                                      } );
          var model = new FileStoreModel( {
                  store: store,
                  rootLabel: 'My HTTP Document Root',
                  checkedRoot: true,
                  checkedStrict: false,
                  iconAttr: "icon"
               });

          function onClick( item, nodeWidget, event ) {
						// Do something after item is clicked....
          }

          ready(function() {
            var tree = new Tree( { model: model,
                                    id: "tree40", persist:false
                                  }, "CheckboxTree" );
            tree.on( "click", onClick );
            tree.startup();
          });
        });
    </script>

  </head>

  <body class="claro">
    <h1 class="DemoTitle">The CheckBox Tree with a dojo/store File Store</h1>
    <p>
      This CheckBox Tree uses the cbtree/store FileStore and the assciated PHP server side
      application to browse the document root of your HTTP server.<br/>
      This example demonstrates lazy loading, that is, the files are only fetched when needed. As a
      result strict parent-child checkbox relationships are disabled. (see the documentation for details).
    </p>
    <p>
      The HTTP server running this demo <b>MUST</b> have PHP support enabled and provide PHP support for JSON.
    </p>
    <div id="CheckboxTree">
    </div>
  </body>
</html>